import json

from home.models import *


def common_hottages_news(request):
    news = Article.objects.order_by("-create_time")[:3]
    hot_tags = Article.objects.values("tags").order_by("total_views").distinct()[:9]

    if 'login_name' in request.COOKIES:
        username = request.COOKIES.get('login_name')
        username = json.loads(username)
    else:
        username = ""
    return {"news": news, "hot_tags": hot_tags, "username": username}
